/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Tp_logDAOImpl implements orm.dao.Tp_logDAO {
	public Tp_log loadTp_logByORMID(int l_id) throws PersistentException {
		try {
			PersistentSession session = orm.Bdprueba2PdsPersistentManager.instance().getSession();
			return loadTp_logByORMID(session, l_id);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log getTp_logByORMID(int l_id) throws PersistentException {
		try {
			PersistentSession session = orm.Bdprueba2PdsPersistentManager.instance().getSession();
			return getTp_logByORMID(session, l_id);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log loadTp_logByORMID(int l_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdprueba2PdsPersistentManager.instance().getSession();
			return loadTp_logByORMID(session, l_id, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log getTp_logByORMID(int l_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdprueba2PdsPersistentManager.instance().getSession();
			return getTp_logByORMID(session, l_id, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log loadTp_logByORMID(PersistentSession session, int l_id) throws PersistentException {
		try {
			return (Tp_log) session.load(orm.Tp_log.class, new Integer(l_id));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log getTp_logByORMID(PersistentSession session, int l_id) throws PersistentException {
		try {
			return (Tp_log) session.get(orm.Tp_log.class, new Integer(l_id));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log loadTp_logByORMID(PersistentSession session, int l_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tp_log) session.load(orm.Tp_log.class, new Integer(l_id), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log getTp_logByORMID(PersistentSession session, int l_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tp_log) session.get(orm.Tp_log.class, new Integer(l_id), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log[] listTp_logByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdprueba2PdsPersistentManager.instance().getSession();
			return listTp_logByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log[] listTp_logByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdprueba2PdsPersistentManager.instance().getSession();
			return listTp_logByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log[] listTp_logByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tp_log as Tp_log");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Tp_log[]) list.toArray(new Tp_log[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log[] listTp_logByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tp_log as Tp_log");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Tp_log[]) list.toArray(new Tp_log[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log loadTp_logByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdprueba2PdsPersistentManager.instance().getSession();
			return loadTp_logByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log loadTp_logByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdprueba2PdsPersistentManager.instance().getSession();
			return loadTp_logByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log loadTp_logByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Tp_log[] tp_logs = listTp_logByQuery(session, condition, orderBy);
		if (tp_logs != null && tp_logs.length > 0)
			return tp_logs[0];
		else
			return null;
	}
	
	public Tp_log loadTp_logByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Tp_log[] tp_logs = listTp_logByQuery(session, condition, orderBy, lockMode);
		if (tp_logs != null && tp_logs.length > 0)
			return tp_logs[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTp_logByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdprueba2PdsPersistentManager.instance().getSession();
			return iterateTp_logByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTp_logByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdprueba2PdsPersistentManager.instance().getSession();
			return iterateTp_logByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTp_logByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tp_log as Tp_log");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTp_logByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tp_log as Tp_log");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log createTp_log() {
		return new orm.Tp_log();
	}
	
	public boolean save(orm.Tp_log tp_log) throws PersistentException {
		try {
			orm.Bdprueba2PdsPersistentManager.instance().saveObject(tp_log);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Tp_log tp_log) throws PersistentException {
		try {
			orm.Bdprueba2PdsPersistentManager.instance().deleteObject(tp_log);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Tp_log tp_log) throws PersistentException {
		try {
			orm.Bdprueba2PdsPersistentManager.instance().getSession().refresh(tp_log);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Tp_log tp_log) throws PersistentException {
		try {
			orm.Bdprueba2PdsPersistentManager.instance().getSession().evict(tp_log);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tp_log loadTp_logByCriteria(Tp_logCriteria tp_logCriteria) {
		Tp_log[] tp_logs = listTp_logByCriteria(tp_logCriteria);
		if(tp_logs == null || tp_logs.length == 0) {
			return null;
		}
		return tp_logs[0];
	}
	
	public Tp_log[] listTp_logByCriteria(Tp_logCriteria tp_logCriteria) {
		return tp_logCriteria.listTp_log();
	}
}
